{
LANG : PASCAL
PROB : crypt1
}

program CRYPT1;
const
  fi = 'crypt1.in';
  fo = 'crypt1.out';
var
  free : array[0..9] of boolean;
  a, b, n : integer;
  count : longint;

procedure inp;
var
  i, c: integer;
begin
  fillchar(free, sizeof(free), false);
  read(n);
  for i := 1 to n do
  begin
    read(c);
    free[c] := true;
  end;
end;

function ok(k : integer) : boolean;
begin
  ok := false;
  while k > 0 do
  begin
    if not free[k mod 10] then exit;
    k := k div 10;
  end;
  ok := true;
end;

procedure process;
var
  t1, t2, t : longint;
begin
  count := 0;
  for a := 11 to 99 do
    if ok(a) then
      for b := 111 to 9999 div a do
        if ok(b) then
        begin
          t1 := b*(a div 10);
          t2 := b*(a mod 10);
          t := b*a;
          if (t1 <= 999) and (t2 <= 999) and (t <= 9999) then
            if ok(t1) and ok(t2) and ok(t) then inc(count);
        end;
end;

begin
  assign(input, fi); reset(input);
  assign(output, fo); rewrite(output);
  inp;
  process;
  writeln(count);
  close(output);
  close(input);
end.